<%@ page import="entity.User" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<table border="1" cellspacing="0">
    <tr>
        <th>id</th>
        <th>username</th>
        <th>password</th>
    </tr>
    <%--写java代码 在<%%>--%>
    <% List<User> userList = (List<User>) request.getAttribute("userList");
        for (User user : userList) {
    %>
    <tr>
        <td><%=user.getId()%></td>
        <td><%=user.getUsername()%></td>
        <td><%=user.getPassword()%></td>
    </tr>
    <%
        }
    %>
</table>
<%--创建对象--%>
<jsp:useBean id="u" class="entity.User"/>
<%--赋值--%>
<jsp:setProperty name="u" property="id" value="3"/>
<jsp:setProperty name="u" property="username" value="wangwu"/>
<jsp:setProperty name="u" property="password" value="123"/>
<%--取值输出--%>
<jsp:getProperty name="u" property="id"/>
<jsp:getProperty name="u" property="username"/>
<jsp:getProperty name="u" property="password"/>

<%--转发--%>
<%--<jsp:forward page="index.jsp"></jsp:forward>--%>

<% String key1 = (String) request.getAttribute("key1");
    String key2 = (String) session.getAttribute("key2");
    String k2 = (String) request.getSession().getAttribute("key2");
    String key3 = (String) application.getAttribute("key3");

    pageContext.setAttribute("key4","value4");
    Object key4 = pageContext.getAttribute("key4");
%>
<br>
<%= key1%>
<%= key2%>
<%= k2%>
<%= key3%>
<%= key4%>
<%--el表达式--%>
<br>
${key1}
${key2}
${key3}
${key4}
</body>
</html>
